﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Company/Company.master" Inherits="WebManager.BasePage" %>

<%@ Import Namespace="TalentPools.BLL" %>
<%@ Import Namespace="TalentPools.Model" %>
<script runat="server">
    
    string session;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsQyLogin())
        {
            JsWindows("请登录", "../Index.aspx");
            return;
        }
        else
        {
            session = Request.Cookies["qyUser"].Values["name"];
            CompanyClass.CheckBaseMeanCount(session);//判断是否已经填写了基本信息
        }
        if (!IsPostBack)
        {
            ManagerVoid();
            string qstr = QueryString("Action");
            switch (qstr)
            {
                case "Add":
                    AddP.Visible = true;
                    EditP.Visible = false;
                    manageP.Visible = false;
                    BindData1();
                    break;
                case "Edit":
                    EditVoid();
                    break;
                case "Del":
                    DelVoid();
                    break;
            }
        }
    }
    private void EditVoid()
    {
        AddP.Visible = false;
        manageP.Visible = false;
        EditP.Visible = true;
        CompanyClass.CheckBaseMeanCount(session);
        BindData();
        int id = Convert.ToInt32(Request.QueryString["id"]);
        invite_info invite = new invite_infoManager().GetInviteObj(id);//获取招聘信息
        ddleditzw.SelectedValue = invite.Zpzw;
        txteditczw.Text = invite.Zpczw;
        rbeditwtype.SelectedValue = invite.Zptype;
        txteditrs.Text = invite.Zprs.ToString();
        rbeditsex.SelectedValue = invite.Zpsex;
        txteditmin.Text = invite.Zpminyear;
        txteditmax.Text = invite.Zpmaxyear;
        ddleditwy.SelectedValue = invite.Zpworkyear;
        ddleditzz.SelectedValue = invite.Zpzz;
        txtedithk.Text = invite.Zphk;
        txteditwp.Text = invite.Zpwp;
        ddleditmoney.SelectedValue = invite.Zpmoney;
        txteditlxr.Text = invite.Zplxr;
        txteditcell.Text = invite.Zpmobile;
        txteditemail.Text = invite.Zpemail;
        txteditaddress.Text = invite.Zpadd;
    }
    private void BindData()
    {
        //绑定工作性质
        rbeditwtype.DataSource = new baseConfigManager().getconfigInfo("工作性质");
        rbeditwtype.DataTextField = "value";
        rbeditwtype.DataValueField = "value";
        rbeditwtype.DataBind();
        //绑定职位
        ddleditzw.DataSource = new baseConfigManager().getconfigInfo("职位");
        ddleditzw.DataTextField = "value";
        ddleditzw.DataValueField = "value";
        ddleditzw.DataBind();
        //绑定政治面貌
        ddleditzz.DataSource = new baseConfigManager().getconfigInfo("政治面貌");
        ddleditzz.DataValueField = "value";
        ddleditzz.DataTextField = "value";
        ddleditzz.DataBind();
        //工作时间
        ddleditwy.DataSource = new baseConfigManager().getconfigInfo("工作时间");
        ddleditwy.DataValueField = "value";
        ddleditwy.DataTextField = "value";
        ddleditwy.DataBind();
        //绑定月薪
        ddleditmoney.DataSource = new baseConfigManager().getconfigInfo("薪资");
        ddleditmoney.DataValueField = "value";
        ddleditmoney.DataTextField = "value";
        ddleditmoney.DataBind();

    }
    private void BindData1()
    {
        //绑定工作性质
        rbwtype.DataSource = new baseConfigManager().getconfigInfo("工作性质");
        rbwtype.DataTextField = "value";
        rbwtype.DataValueField = "value";
        rbwtype.DataBind();
        rbwtype.SelectedIndex = 0;
        //绑定职位
        ddlzw.DataSource = new baseConfigManager().getconfigInfo("职位");
        ddlzw.DataTextField = "value";
        ddlzw.DataValueField = "value";
        ddlzw.DataBind();
        //绑定政治面貌
        ddlzz.DataSource = new baseConfigManager().getconfigInfo("政治面貌");
        ddlzz.DataValueField = "value";
        ddlzz.DataTextField = "value";
        ddlzz.DataBind();
        //工作时间
        ddlwy.DataSource = new baseConfigManager().getconfigInfo("工作时间");
        ddlwy.DataValueField = "value";
        ddlwy.DataTextField = "value";
        ddlwy.DataBind();
        //绑定月薪
        ddlmoney.DataSource = new baseConfigManager().getconfigInfo("薪资");
        ddlmoney.DataValueField = "value";
        ddlmoney.DataTextField = "value";
        ddlmoney.DataBind();

    }
    private void DelVoid()
    {
        int id = Convert.ToInt32(QueryString("id"));
        if (new invite_infoManager().DeleteInvite(id))
        {
            ManagerVoid();
        }
    }

    private void ManagerVoid()
    {
        manageP.Visible = true;
        EditP.Visible = false;
        AddP.Visible = false;
        RP1.DataSource = new invite_infoManager().GetInviteList(session);
        RP1.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        invite_info invite = new invite_info();
        invite.Zpzw = ddlzw.SelectedValue;
        invite.Zpczw = txtczw.Text.Trim();
        invite.Zpsex = rbsex.SelectedValue;
        invite.Zptype = rbwtype.SelectedValue;
        invite.Zpworkyear = ddlwy.SelectedValue;
        invite.Zpminyear = txtmin.Text.Trim();
        invite.Zpmaxyear = txtmax.Text.Trim();
        invite.Zpzz = ddlzz.SelectedValue;
        invite.Zphk = txthk.Text.Trim();
        invite.Zpwp = txtwp.Text.Trim();
        invite.Zpmoney = ddlmoney.SelectedValue;
        invite.Zpdes = txtdes.Text.Trim();
        invite.Zplxr = txtlxr.Text.Trim();
        invite.Zpmobile = txtcell.Text.Trim();
        invite.Zpadd = txtaddress.Text.Trim();
        invite.Zpemail = txtemail.Text.Trim();
        invite.CompanyName = session;
        if (new invite_infoManager().InsertInvite(invite))
        {
            Label1.Text = "添加成功";
            ManagerVoid();
        }
        else
        {
            Label1.Text = "添加失败，如果信息填写无误，请联系管理员解决";
        }
    }
    public string sf()
    {
        string jj = Eval("Zpdes").ToString();
        if (jj.Length >= 16)
        {
            return jj.Substring(0, 14);
        }
        else if (jj.Length > 0)
        {
            return jj;
        }
        else
        {
            return "<span style='color:blue;''>没有待遇说明和具体要求</span>";
        }
    }
    public string sf1()
    {
        string cwz = Eval("Zpczw").ToString();
        if (cwz.Length == 0)
        {
            return "<span style='color:blue'>没有自定义职位名称</span>";
        }
        return cwz;
    }
    protected void btnSubmit_edit_Click(object sender, EventArgs e)
    {
        invite_info invite = new invite_info();
        invite.Zpzw = ddleditzw.SelectedValue;
        invite.Zpsex = rbeditsex.SelectedValue;
        invite.Zpczw = txteditczw.Text.Trim();
        invite.Zptype = rbeditwtype.SelectedValue;
        invite.Zpworkyear = ddleditwy.SelectedValue;
        invite.Zpminyear = txteditmin.Text.Trim();
        invite.Zpmaxyear = txteditmax.Text.Trim();
        invite.Zpzz = ddleditzz.SelectedValue;
        invite.Zphk = txtedithk.Text.Trim();
        invite.Zpwp = txteditwp.Text.Trim();
        invite.Zpmoney = ddleditmoney.SelectedValue;
        invite.Zpdes = txteditdes.Text.Trim();
        invite.Zplxr = txteditlxr.Text.Trim();
        invite.Zpmobile = txteditcell.Text.Trim();
        invite.Zpadd = txteditaddress.Text.Trim();
        invite.Zpemail = txteditemail.Text.Trim();
        invite.CompanyName = session;
        if (new invite_infoManager().UpdateInvite(invite))
        {
            Label2.Text = "修改成功";
            ManagerVoid();
        }
        else
        {
            Label2.Text = "修改失败，如果信息填写无误，请联系管理员";
        }
    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table width='100%' border='0' align='center' cellpadding='4' cellspacing='1' class='border'>
        <tr class='topbg'>
            <td colspan="2" align='center'>
                <strong class="Glow">招 聘 管 理</strong>
            </td>
        </tr>
        <tr class='tdbg'>
            <td width='70'>
                <strong>导航：</strong>
            </td>
            <td>
                <a href="?Action=Add">新增招聘</a> | <a href="JobManager.aspx">招聘列表</a>
            </td>
        </tr>
    </table>
    <br />
    <asp:Panel ID="EditP" runat="server" Width="100%" Visible="false">
        <div>
            <table width='100%' border='0' align='center' cellpadding='4' cellspacing='1' class='border'>
                <tr class='tdbg'>
                    <td colspan="2" class="topbg2">
                        <div align="center" class="Glow">
                            <strong>企业招聘表</strong></div>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td width="23%" class="tdbg1">
                        <div align="right">
                            <span class="style4">*</span>招聘职位：</div>
                        <div align="right">
                            自定义职位：</div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:DropDownList ID="ddleditzw" runat="server">
                        </asp:DropDownList>
                        &nbsp;<span class="style4">* </span>
                        <br />
                        <asp:TextBox ID="txteditczw" runat="server"></asp:TextBox>&nbsp;<span class="style4"></span>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            工作类型：</div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:RadioButtonList ID="rbeditwtype" runat="server" RepeatDirection="Horizontal"
                            RepeatLayout="Flow">
                            <asp:ListItem Selected="True" Value="不限">不限</asp:ListItem>
                            <asp:ListItem Value="全职">全职</asp:ListItem>
                            <asp:ListItem Value="兼职">兼职</asp:ListItem>
                            <asp:ListItem Value="临时工">临时工</asp:ListItem>
                            <asp:ListItem Value="合同工">合同工</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <span class="style4">*</span>招聘人数：</div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:TextBox ID="txteditrs" runat="server" Width="40px"></asp:TextBox>人
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            要求性别：</div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:RadioButtonList ID="rbeditsex" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                            <asp:ListItem Value="男">男</asp:ListItem>
                            <asp:ListItem Value="女">女</asp:ListItem>
                            <asp:ListItem Selected="True" Value="不限">不限</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            要求年龄：</div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:TextBox ID="txteditmin" runat="server" MaxLength="2" Width="50px">18</asp:TextBox>岁—<asp:TextBox
                            ID="txteditmax" runat="server" MaxLength="2" Width="50px">30</asp:TextBox>岁
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <div align="right">
                                工作经验：</div>
                        </div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:DropDownList ID="ddleditwy" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <div align="right">
                                政治面貌：</div>
                        </div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:DropDownList ID="ddleditzz" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <div align="right">
                                户口要求：</div>
                        </div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:TextBox ID="txtedithk" runat="server" MaxLength="20"></asp:TextBox>（注：不填表示不限户口）
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <div align="right">
                                <span class="style4">*</span>工作地区：</div>
                        </div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:TextBox ID="txteditwp" runat="server"></asp:TextBox>
                        &nbsp;<span class="style4">*地点不能选不限。数据成功添加后，该项不可修改</span>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <div align="right">
                                提供月薪：</div>
                        </div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:DropDownList ID="ddleditmoney" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <span class="style4">*</span>具体要求与待遇：</div>
                    </td>
                    <td class="tdbg2" style="width: 482px">
                        <asp:TextBox ID="txteditdes" runat="server" Height="138px" TextMode="MultiLine" Width="343px"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <br />
            <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
                <tr class='tdbg'>
                    <td colspan="2" class="topbg2">
                        <div align="center" class="Glow">
                            <strong>联系方式</strong></div>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td width="23%" class="tdbg1">
                        <div align="right">
                            <span class="style4">*</span>联系人：</div>
                    </td>
                    <td width="77%" class="tdbg2">
                        <asp:TextBox ID="txteditlxr" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <span class="style4">*</span>手机号码：</div>
                    </td>
                    <td class="tdbg2">
                        <asp:TextBox ID="txteditcell" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <span class="style4"></span>电子邮箱：</div>
                    </td>
                    <td class="tdbg2">
                        <asp:TextBox ID="txteditemail" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr class='tdbg'>
                    <td class="tdbg1">
                        <div align="right">
                            <span class="style4">*</span>联系地址：</div>
                    </td>
                    <td class="tdbg2">
                        <asp:TextBox ID="txteditaddress" runat="server"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <table width="100%" border="0">
                <tr>
                    <td>
                        <div align="center">
                            &nbsp;<asp:Button ID="btnSubmit_edit" runat="server" Text="提 交" OnClick="btnSubmit_edit_Click" />&nbsp;
                            <label>
                                <input type="reset" name="Submit2" value="重 置" /><br />
                                <asp:Label ID="Label2" runat="server" ForeColor="Red"></asp:Label></label></div>
                    </td>
                </tr>
            </table>
        </div>
    </asp:Panel>
    <asp:Panel ID="AddP" runat="server" Width="100%" Visible="false">
        <table width='100%' border='0' align='center' cellpadding='4' cellspacing='1' class='border'>
            <tr class='tdbg'>
                <td colspan="2" class="topbg2">
                    <div align="center" class="Glow">
                        <strong>新 增 招 聘 信 息</strong></div>
                </td>
            </tr>
            <tr class='tdbg'>
                <td width="23%" class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>招聘职位：</div>
                    <div align="right">
                        自定义职位：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <input type="hidden" name="position" />
                    <asp:DropDownList ID="ddlzw" runat="server">
                    </asp:DropDownList>
                    &nbsp;<br />
                    <asp:TextBox ID="txtczw" runat="server"></asp:TextBox>&nbsp;<span class="style4"></span>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        工作类型：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:RadioButtonList ID="rbwtype" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>招聘人数：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtrs" runat="server" Width="40px"></asp:TextBox>人
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        要求性别：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:RadioButtonList ID="rbsex" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                        <asp:ListItem Value="男">男</asp:ListItem>
                        <asp:ListItem Value="女">女</asp:ListItem>
                        <asp:ListItem Selected="True" Value="不限">不限</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        要求年龄：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtmin" runat="server" MaxLength="2" Width="50px">18</asp:TextBox>岁—<asp:TextBox
                        ID="txtmax" runat="server" MaxLength="2" Width="50px">30</asp:TextBox>岁
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            工作经验：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:DropDownList ID="ddlwy" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            政治面貌：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:DropDownList ID="ddlzz" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            户口要求：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txthk" runat="server" MaxLength="20"></asp:TextBox>（注：不填表示不限户口）
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            <span class="style4">*</span>工作地区：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <input type="hidden" name="workadd" />
                    <asp:TextBox ID="txtwp" runat="server"></asp:TextBox>
                    &nbsp;
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <div align="right">
                            提供月薪：</div>
                    </div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:DropDownList ID="ddlmoney" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>具体要求与待遇：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:TextBox ID="txtdes" runat="server" Height="138px" TextMode="MultiLine" Width="343px"></asp:TextBox>
                </td>
            </tr>
        </table>
        <br />
        <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
            <tr class='tdbg'>
                <td colspan="2" class="topbg2">
                    <div align="center" class="Glow">
                        <strong>联系方式</strong></div>
                </td>
            </tr>
            <tr class='tdbg'>
                <td width="23%" class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>联系人：</div>
                </td>
                <td width="77%" class="tdbg2">
                    <asp:TextBox ID="txtlxr" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>手机号码：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtcell" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4"></span>电子邮箱：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        <span class="style4">*</span>联系地址：</div>
                </td>
                <td class="tdbg2">
                    <asp:TextBox ID="txtaddress" runat="server"></asp:TextBox>
                </td>
            </tr>
        </table>
        <table width="100%" border="0">
            <tr>
                <td>
                    <div align="center">
                        &nbsp;<asp:Button ID="btnSubmit" runat="server" OnClick="Button1_Click" Text="提 交" />&nbsp;
                        <label>
                            <input type="reset" name="Submit2" value="重 置" /><br />
                            <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label></label></div>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="manageP" runat="server" Width="100%" Visible="False">
        <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
            <tr class='topbg2'>
                <td width="7%" align='center' style="height: 24px">
                    <strong class="Glow">序号</strong>
                </td>
                <td width="10%" align='center' style="height: 24px">
                    <strong class="Glow">职位名称</strong>
                </td>
                <td width="13%" align='center' style="height: 24px">
                    <strong class="Glow">自定义职位名称</strong>
                   
                </td>
                <td width="9%" align='center' style="color: #000000; height: 24px">
                    <strong class="Glow">招聘人数</strong>
                </td>
                <td width="19%" align='center' style="height: 24px">
                    <strong class="Glow">具体要求</strong>
                </td>
                <td width="19%" align='center' style="height: 24px">
                    <strong class="Glow">操作</strong>
                </td>
            </tr>
            <asp:Repeater ID="RP1" runat="server">
                <ItemTemplate>
                    <tr class='tdbg'>
                        <td align='center'>
                            <%#Eval("Id") %>
                        </td>
                        <td>
                            <%#Eval("Zpzw") %>
                        </td>
                        <td>
                            <%#sf1() %>
                        </td>
                        <td>
                            <%#Eval("Zprs") %>
                        </td>
                        <td>
                            <%#sf() %>
                        </td>
                        <td align='center'>
                            <a href="JobManager.aspx?id=<%#Eval("Id")%>&amp;Action=Edit">修改</a> | <a href="JobManager.aspx?id=<%#Eval("Id") %>&amp;Action=Del"
                                onclick="return confirm('确定要删除此项吗？此操作不可逆。');">删除</a>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
    </asp:Panel>
</asp:Content>
